package com.wxd.controller;


import com.sun.javafx.collections.MappingChange;
import com.wxd.entity.Admin;
import com.wxd.service.AdminService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxd
 * @since 2022-03-08
 */
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Resource private AdminService as;
    @PostMapping("/add")
    public Map<String,Object> addAdmin(@RequestBody Admin admin){
        as.save(admin);
        return new HashMap<String, Object>(){{
            put("status","success");
        }};
    }
    @PutMapping("/update")
    public Map<String, Object> updateAdmin(@RequestBody Admin admin){
        as.updateById(admin);
        return new HashMap<String, Object>(){{
            put("status","success");
        }};
    }
}

